var app = getApp();

Page({
    data: {
        status: 1,
        mygd:false
    },
    onLoad: function(n) {
        app.setNavigationBarColor(this);
        this.GetYajinList();
    },
    ChangeList: function(t) {
        let t_status = t.currentTarget.dataset.status;
        if (t_status != this.data.status) {
            this.setData({
                status: t_status,
                depositList: [],
                mygd:false
            });
            if (t_status == 1) {
                this.GetYajinList();
            } else if (t_status == 2) {
                this.GetApplyRefundList();
            }
        }
    },
    GetYajinList: function() {
        var o = this,
            u_id = wx.getStorageSync("users").id;
        app.util.request({
            url: "entry/wxapp/GetYajinList",
            cachetime: "0",
            data: {
                user_id: u_id,
                page: 1,
                pagesize: 1000
            },
            success: function(n) {
                o.setData({
                    depositList: n.data
                });
                setTimeout(()=>{
                    o.setData({
                        mygd: true
                    });
                },500)
            }
        });
    },
    GetApplyRefundList: function() {
        let o = this,
            u_id = wx.getStorageSync("users").id;
        app.util.request({
            url: "entry/wxapp/GetApplyRefundList",
            cachetime: "0",
            data: {
                user_id: u_id,
                page: 1,
                pagesize: 1000
            },
            success: function(n) {
                o.setData({
                    depositList: n.data
                });
                setTimeout(() => {
                    o.setData({
                        mygd: true
                    });
                }, 500)
            }
        });
    },
    ToRefundApply: function(t) {
        let o = this,
            u_id = wx.getStorageSync("users").id;

        let t_money = t.currentTarget.dataset.money,
            t_store_id = t.currentTarget.dataset.store_id;

        app.util.request({
            url: "entry/wxapp/ToRefundApply",
            cachetime: "0",
            data: {
                user_id: u_id,
                money: t_money,
                store_id: t_store_id
            },
            success: function(n) {
                wx.showToast({
                    title: '申请成功',
                    icon: 'success',
                    duration: 2000
                })
                setTimeout(() => {
                    o.setData({
                        status: 2,
                        depositList: []
                    });
                    o.GetApplyRefundList();
                }, 2000)
            }
        });
    }
});